<?php 
    require_once($_SERVER["DOCUMENT_ROOT"]."/global.php");
    require_once($_SERVER["DOCUMENT_ROOT"]."/modules/security_mod.php");
    require_once($_SERVER["DOCUMENT_ROOT"]."/modules/account_mod.php");

    SecurityMod::loginDynaScript();
    if(isset($_SESSION["account"])){
        $level = $_SESSION["account"]->getLevel();

        // BASIC security level:
        if($_SESSION["account"]->getBasic() == 1 || $_SESSION["account"]->getSecret() == 1 || $level = "Admin"){
            // The dynascript scripts themselves. So that users know that new version is available.
            echo "<div scriptName='DynaScript runtime' version='2.0' target='GM' scriptDesc='Runtime environment for handling DynaScript scripts.'>";
                echo "<script type='text/javascript' src='dynascript/dynascriptruntime.user.js'></script>";
                echo "<div name='user_config'>";
                    echo "<div name='ds_local_dev' type='bool' label='Use alternate location?' default='false' description='Check this if you want the page scripts to be loaded from local drive instead from the server. This will apply also to the dynascript.php file.'></div>";
                    echo "<div name='ds_local_dev_path' type='text' label='Path for local development' default='file:///c:/temp/pardus/dev' description='Path to a folder where the local development files are stored.'></div>";
                    echo "<div name='ds_suppress_script_caching' type='bool' label='Suppress scripts caching' default='false' description='Check this if you want to always load scripts from server instead of using browser cache.'></div>";
                echo "</div>";
            echo "</div>";
            echo "<div scriptName='DynaScript Control Panel' version='2.8' target='GM' scriptDesc='Control panel for DynaScript. It is the stuff you see right now.'>";
                echo "<script type='text/javascript' src='dynascript/dynascriptcontrolpanel.user.js'></script>";
            echo "</div>";

            // Project Orion - MSGFrame alert
            echo "<div scriptName='PO Msgframe Alert' version='2.1' target='page' scriptDesc='Shows the new alerts information in the MSG frame.' longDesc='scripts/po_mfa/po_mfa.txt' allowedUniverses='Orion'>";
                echo "<script type='text/javascript' src='scripts/po_utils/po_utils.js' includes='menu.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_mfa/po_mfa_menu.js' includes='menu.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_utils/po_utils.js' includes='msgframe.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_mfa/po_mfa.js' includes='msgframe.php'></script>";
                echo "<div name='user_config'>";
                    echo "<div name='po_mfa_show_fed' type='bool' label='Show alerts in Federation space' default='true' description='Check this checkbox if you want to receive alerts from the Federation clusters'></div>";
                    echo "<div name='po_mfa_show_uni' type='bool' label='Show alerts in Union space' default='false' description='Check this checkbox if you want to receive alerts from the Union clusters'></div>";
                    echo "<div name='po_mfa_show_emp' type='bool' label='Show alerts in Empire space' default='false' description='Check this checkbox if you want to receive alerts from the Empire clusters'></div>";
                    echo "<div name='po_mfa_show_neu' type='bool' label='Show alerts in Neutral space' default='false' description='Check this checkbox if you want to receive alerts from the Neutral clusters'></div>";
                echo "</div>";
            echo "</div>";

            // Only display FF List manager lite if user doesn't have right to the full FF list manager:
            if($_SESSION["account"]->getAdmin() == 0 && $_SESSION["account"]->getSecret() == 0 && $level != "Admin"){
                // Project Orion - Friend-Foe List Manager Lite
                echo "<div scriptName='PO FF list manager lite' version='1.0' target='page' scriptDesc='Allows you to download Friend/Foe list defined by the faction and mark pilots accordingly in the Other Ships window.' longDesc='scripts/po_ffm/po_ffm_lite.txt' allowedUniverses='Orion'>";
                    echo "<script type='text/javascript' src='scripts/po_utils/po_utils.js' includes='menu.php'></script>";
                    echo "<script type='text/javascript' src='scripts/po_ffm/po_ffm_menu.js' includes='menu.php'></script>";
                    echo "<script type='text/javascript' src='scripts/po_utils/po_utils.js' includes='main.php'></script>";
                    echo "<script type='text/javascript' src='scripts/po_ffm/po_ffm_nav.js' includes='main.php'></script>";
                    echo "<div name='user_config'>";
                        echo "<div name='po_ffm_my_settings' hidden='true' type='text' label='Your own settings' default='' description='Settings created by yourself. Clearing temporary nternet files will delete it so I suggest you to make a copy on a safe place.'></div>";
                        echo "<div name='po_ffm_faction_settings' hidden='true' type='text' label='Settings from your faction' default='' description='If you get settings from your faction, put them here.'></div>";
                        echo "<div name='po_ffm_faction_overrides' hidden='true' type='bool' label='Faction settings have higher priority' default='true' description='In case of conflicting stuff in your and faction settings the faction settings will be used if the checkbox is checked.'></div>";
                        echo "<div name='po_ffm_report_individual' hidden='true' type='bool' label='Report individualsfoelisted by faction' default='true' description='In case you meet a foelisted individual pilot, they will be reported automatically to the logger as a sighting.'></div>";
                        echo "<div name='po_ffm_sort_pilots' hidden='true' type='bool' label='Sort pilots in Other Ships window' default='false' description='Pilots in the Other Ships window will be sorted. Foes will appear on the top, then friends and then neutrals.'></div>";
                    echo "</div>";
                echo "</div>";
            }

            // Project Orion - Sector Danger Overlay
            echo "<div scriptName='PO Sector Danger Overlay' version='2.3' target='page' scriptDesc='Shows the alert in the map and allow pilots to submit alerts and sightings.' longDesc='scripts/po_sdo/po_sdo.txt' allowedUniverses='Orion'>";
                echo "<script type='text/javascript' src='scripts/po_utils/po_utils.js' includes='menu.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_sdo/po_sdo_menu.js' includes='menu.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_utils/po_utils.js' includes='main.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_sdo/po_sdo.js' includes='main.php'></script>";
                echo "<div name='user_config'>";
                    echo "<div name='po_sdo_show_nav_frame' type='bool' label='Show colored frame around NAV area' default='true' description='Check this checkbox if you want to see colored frame around the NAV area. The color depends on the amount of alerts in the current sector.'></div>";
                    echo "<div name='po_sdo_show_overlay' type='bool' label='Show colored overlay info in teh NAV area' default='true' description='Check this checkbox want to see colored overlay information at each tile with Alert.'></div>";
                echo "</div>";
            echo "</div>";

            // Project Orion - AutoLogger 
            echo "<div scriptName='PO AutoLogger' version='1.2' target='page' scriptDesc='Automatically send combat and hack logs to the infocentre database' longDesc='scripts/po_alog/po_alog.txt' allowedUniverses='Orion'>";
                echo "<script type='text/javascript' src='scripts/po_utils/po_utils.js' includes='combat_details.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_alog/po_alog_cmbt.js' includes='combat_details.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_alog/po_alog_cmbt_list.js' includes='overview_combat_log.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_utils/po_utils.js' includes='hack.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_alog/po_alog_hack.js' includes='hack.php'></script>";
            echo "</div>";

            // Project Orion - PFC Base Population Assistant 
            echo "<div scriptName='PO PFC Base Population Assistant' version='1.3' target='page' scriptDesc='Remembers the population levels of PFC bases and tells you if it dropped or increased since last visit' longDesc='scripts/po_pbpa/po_pbpa.txt' allowedUniverses='Orion'>";
                echo "<script type='text/javascript' src='scripts/po_utils/po_clock_utils.js' includes='menu.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_utils/po_utils.js' includes='statistics.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_pbpa/po_pbpa_stats.js' includes='statistics.php'></script>";
                echo "<div name='user_config'>";
                    echo "<div name='po_pbpa_definition_url' type='text' hidden='true' label='URL of the sheet with SB definitions' default='0Ank-9nlbg_XqdGViWk5IellKWS0xQUFFeHYwOXdhN1E' description='URL of the sheet with SB definitions'></div>";
                echo "</div>";
            echo "</div>";


            // Project Orion - Combat notification assistant 
            echo "<div scriptName='PO Combat Notification Assistant' version='1.0' target='page' scriptDesc='Plays a sound on incoming COMBAT or MSG notification in Msgframe. NOTE: Works only with FF8 and higher.' longDesc='scripts/po_cna/po_cna.txt' allowedUniverses='Orion'>";
                echo "<script type='text/javascript' src='scripts/po_cna/po_cna_msgframe.js' includes='msgframe.php'></script>";
            echo "</div>";
            
            // Project Orion - Clock 
            echo "<div scriptName='PO Clock' version='1.3' target='page' scriptDesc='Shows clock' longDesc='scripts/po_clock/po_clock.txt' allowedUniverses='Orion'>";
                echo "<script type='text/javascript' src='scripts/po_utils/po_clock_utils.js' includes='menu.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_utils/po_utils.js' includes='main.php;logout.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_clock/po_clock_nav.js' includes='main.php;msgframe.php'></script>";
                echo "<div name='user_config'>";
                    echo "<div name='po_clock_msgframe_only' type='bool' label='Place clock permanently (and only) in Msgframe' default='false' description='If checked, the clock won't be shown in NAV screen at all.'></div>";
                echo "</div>";
            echo "</div>";
        }
    // >>>>>> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! <<<<<<
    // >>>>>> The scripts below should only come to trusted pilots <<<<<<
    // >>>>>> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! <<<<<<

        // ADVANCED scripts, for advanced scripts users:
        if($_SESSION["account"]->getAdvanced() == 1 || $_SESSION["account"]->getSecret() == 1 || $level = "Admin"){
            // Project Orion - Manual Alert Submit 
            echo "<div scriptName='PO Manual Alert Submit' version='1.0' target='page' scriptDesc='Adds links to the OtherShips window which enables you to submit Sightings/Alerts/SafeTiles manually' longDesc='scripts/po_mas/po_mas.txt' allowedUniverses='Orion'>";
                echo "<script type='text/javascript' src='scripts/po_utils/po_utils.js' includes='main.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_mas/po_mas_nav.js' includes='main.php'></script>";
            echo "</div>";
        }

        // SECRET scripts, only for users with secret scripts clearance:
        if($_SESSION["account"]->getSecret() == 1 || $level == "Admin"){
            // Project Orion - Combat Assistant
            echo "<div scriptName='PO Combat Assistant' version='1.9' target='page' scriptDesc='Helps pilots attacking other pilots to be faster and safer.' longDesc='scripts/po_bca/po_bca.txt' allowedUniverses='Orion'>";
                echo "<script type='text/javascript' src='scripts/po_utils/po_utils.js' includes='building.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_utils/po_combat_utils.js' includes='building.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_bca/po_bca_building.js' includes='building.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_utils/po_utils.js' includes='ship2ship_combat.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_utils/po_combat_utils.js' includes='ship2ship_combat.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_bca/po_bca_combat.js' includes='ship2ship_combat.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_utils/po_utils.js' includes='main.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_utils/po_combat_utils.js' includes='main.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_bca/po_bca_nav.js' includes='main.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_bca/po_bca_amb.js' includes='ambush.php'></script>";
                echo "<div name='user_config'>";
                    echo "<div name='po_bca_check_all_missiles' type='bool' label='Automatically check all missiles when entering combat screen' default='true' description='Automatically check all missiles when entering combat screen'></div>";
                    echo "<div name='po_bca_default_drugs' type='text' label='Default amount of drugs to take during combat' default='3' description='This amount of drugs will be taken during combat if you push the appropriate hotkey.'></div>";
                    echo "<div name='po_bca_armor_strength' type='text' label='Armor strength of your armor (1-5)' default='5' description='The armor class. Enter the number only without the leading x character'></div>";
                    echo "<div name='po_bca_armor_points' type='text' label='Max armor points of your armor (135-990)' default='500' description='The catalog armor points of your ship. Enter the pure number only.'></div>";
                    echo "<div name='po_bca_prim_ql' type='text' label='Primary Ambush QuickList' default='' description='The primary Ambush Settings'></div>";
                    echo "<div name='po_bca_sec_ql' type='text' label='Secondary Ambush QuickList' default='' description='The secondary Ambush Settings'></div>";
                    echo "<div name='po_bca_use_sec_ql' type='bool' label='If checked, the secondary QL will be used.' default='false' description='If checked, the secondary QL will be imported when pushing the L hotkey in Ambush screen. Otherwise the primary one will be used.'></div>";
                echo "</div>";
            echo "</div>";
        }

        // ADMINISTRATIVE scripts, for users with administrative rights:
        if($_SESSION["account"]->getAdmin() == 1 || $_SESSION["account"]->getSecret() == 1 || $level == "Admin"){
            // Project Orion - Friend-Foe List Manager - admin version
            echo "<div scriptName='PO FF list manager' version='2.1' target='page' scriptDesc='Allows you to set your own list of friends and foes. Useful for fast targetting the enemies.' longDesc='scripts/po_ffm/po_ffm.txt' allowedUniverses='Orion'>";
                echo "<script type='text/javascript' src='scripts/po_utils/po_utils.js' includes='menu.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_ffm/po_ffm_menu.js' includes='menu.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_utils/po_utils.js' includes='diplomacy.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_ffm/po_ffm_dipl.js' includes='diplomacy.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_utils/po_utils.js' includes='diplomacy_adv.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_ffm/po_ffm_dipl_adv.js' includes='diplomacy_adv.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_utils/po_utils.js' includes='main.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_ffm/po_ffm_nav.js' includes='main.php'></script>";
                echo "<div name='user_config'>";
                    echo "<div name='po_ffm_my_settings' type='text' label='Your own settings' default='' description='Settings created by yourself. Clearing temporary nternet files will delete it so I suggest you to make a copy on a safe place.'></div>";
                    echo "<div name='po_ffm_faction_settings' type='text' label='Settings from your faction' default='' description='If you get settings from your faction, put them here.'></div>";
                    echo "<div name='po_ffm_faction_overrides' type='bool' label='Faction settings have higher priority' default='true' description='In case of conflicting stuff in your and faction settings the faction settings will be used if the checkbox is checked.'></div>";
                    echo "<div name='po_ffm_report_individual' type='bool' label='Report individualsfoelisted by faction' default='false' description='In case you meet a foelisted individual pilot, they will be reported automatically to the logger as a sighting.'></div>";
                    echo "<div name='po_ffm_sort_pilots' type='bool' label='Sort pilots in Other Ships window' default='true' description='Pilots in the Other Ships window will be sorted. Foes will appear on the top, then friends and then neutrals.'></div>";
                echo "</div>";
            echo "</div>";
        }
	
	// Project Orion - PFC Base Manager
	if($_SESSION["account"]->getSB() == 1 || $_SESSION["account"]->getSecret() == 1 || $level == "Admin"){
            echo "<div scriptName='PO PFC Base Manager' version='1.1' target='page' scriptDesc='Allows pilots who own an SB in PFC to see the basic planned settings and to submit the SB Tax safely to the AF' longDesc='scripts/po_pbm/po_pbm.txt' allowedUniverses='Orion'>";
                echo "<script type='text/javascript' src='scripts/po_pbm/po_pbm_starbase_overview.js' includes='starbase_overview.php'></script>";
		echo "<script type='text/javascript' src='scripts/po_utils/po_utils.js' includes='overview_sb.php;myalliance.php;ship2ship_transfer.php'></script>";
                echo "<script type='text/javascript' src='scripts/po_pbm/po_pbm_sb_overview.js' includes='overview_sb.php;myalliance.php;ship2ship_transfer.php'></script>";
                echo "<div name='user_config'>";
                    echo "<div name='po_pbm_definition_url' type='text' hidden='true' label='URL of the sheet with SB definitions' default='0Ank-9nlbg_XqdGViWk5IellKWS0xQUFFeHYwOXdhN1E' description='URL of the sheet with SB definitions'></div>";
		    echo "<div name='po_pbm_form_url' type='text' hidden='true' label='URL of the google form to submit the tax records' default='dGViWk5IellKWS0xQUFFeHYwOXdhN1E6MQ' description='URL of the google form to submit the tax records'></div>";
		    echo "<div name='po_pbm_base_coords' type='text' label='The location of your base. E.g. Aya [1,21].' default='' description='The location of your base. E.g. Aya [1,21]. Go to the SB Overview screen to fetch this value automatically.'></div>";
                echo "</div>";
            echo "</div>";
	}
		SecurityMod::logoutDynaScript();
    }else
        SecurityMod::logout();

?>